<?php
header("Content-Type: text/html; charset=utf-8");
/**
 *
 * Enter description here ...
 */
function readFlashFile(){
	$base_path=str_replace('\\','/',dirname(__FILE__));
	$buffer="";
	$buffer=file_get_contents("$base_path/flashData.dat");
 	return  $buffer;
}

/**
 *
 * Enter description here ...
 * @param   $content
 */
function writeFlashFile($content){
	$base_path=str_replace('\\','/',dirname(__FILE__));
	$handle =  fopen("$base_path/flashData.dat", "w+");

	if ($handle) {
		fwrite($handle, $content);
		fclose($handle);
		return  true;
	}else{
		return  false;
	}

}

?>


<?php


$action=$_GET['action'];
if($action=="edit"){
	$content=$_POST["flashContent"];
 

	$ret=writeFlashFile($content);
	if($ret!=true){
		echo "<script>alert('编辑失败！');</script>";
	}else{
		echo "<script>alert('编辑成功！');</script>";
	}
	echo ("<script>document.location='flashFile.php';</script>");
}else{
	$content=readFlashFile();
}

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>flash文件修改</title>
<link rel="stylesheet" type="text/css" href="../skin/css/base.css">

<style type="text/css">
.proItem {
	margin: 20px;
	padding-top: 5px;
	clear: both;
}
 
.proItem  textarea {
	width: 660px;
	height: 140px;
	float: left;
	 
}

.proItem  input.btCenter {
	text-align: center;
	float: center;
	margin-left:200px;
}
</style>
</head>
<body leftmargin="8" topmargin="8" background='../skin/images/allbg.gif'>
<form action="flashFile.php?action=edit" method="post"
	name="productForm" id="productForm">
<div class="proItem">&nbsp;&nbsp;flash文件内容<br />
<textarea id="flashContent" name="flashContent"><?=$content?></textarea></div>
<div class="proItem"><input type="submit" value="提交" class="btCenter" /></div>
</form>
</body>
</html>
